﻿@{
    ViewBag.Title = "用户绑定";
}

<div class="page">
    <header class="bar bar-nav">
        <h1 class="title">用户绑定</h1>
    </header>
    <div class="content">
        <form id="form-bind">
@*            <input type="hidden" id="bind-enter" value="@Model.enter_id" />*@
            <div class="list-block">
                <ul>
                    <!-- Text inputs -->
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-name"></i></div>
                            <div class="item-inner">
                                <div class="item-input">
                                    <input type="text" id="bind-username" placeholder="请输入姓名">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-name"></i></div>
                            <div class="item-inner">
                                <div class="item-input">
                                    <input type="text" id="bind-ShoujiHaoma" placeholder="请输入手机号码">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-name"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">
                                    <input type="text" id="bind-YZM" placeholder="请输入验证码">
                                </div>
                                <div class="item-input">
                                    <input type="button" class="button button-fill button-danger" style="width: 45%; float: right;" onclick="settime(this);" value=" 获取验证码" />
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="content-block">
                <button class="button button-big button-fill">绑 定</button>
            </div>
        </form>
        <div class="copyright">
            <p>厦门一指通智能科技有限公司 </p>
            <p>©2016 www.xmyzt.com.cn</p>
        </div>
    </div>
</div>
<script type="text/javascript">
    var common = {
        postAjax: function (url, data, success) {
            var hs = document.getElementsByName('__RequestVerificationToken');
            if (hs.length > 0) {
                data = data || {};
                data["__RequestVerificationToken"] = hs[0].value;
            }
            $.ajax({
                url: url,
                cache: false,
                type: 'post',
                dataType: 'json',
                data: data,
                success: success
            });
        }
    };
    var countdown = 60;
    function settime(val) {
        var ShoujiHaoma = $('#bind-ShoujiHaoma').val();
        if (!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(ShoujiHaoma))) {
            $.alert("请输入完整的11位手机号");
            return false;
        }
        if (countdown == 0) {
            val.removeAttribute("disabled");
            val.value = "获取验证码";
            countdown = 60;
            return false;
        } else {
            if (countdown == 60) YZM(ShoujiHaoma);
            val.setAttribute("disabled", true);
            val.value = "重新发送(" + countdown + ")";
            countdown--;
        }
        setTimeout(function () {
            settime(val);
        }, 1000);
    }
    var YZM = function (ShoujiHaoma) {
        var enterid = $('#bind-enter').val();
        common.postAjax('/H5/GetYZM', { ShoujiHaoma: ShoujiHaoma, enterId: enterid }, function (result) {
            if (result.Code == 1) {
                $.toast('请查收短信');
            } else {
                $.alert(result.Message);
            }
        });
    }
</script>
